package cn.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class GetDateTimeUtil {

	/**
	 * 取当前时间戳 17位，带毫秒
	 * 
	 * @return
	 */
	public static String NewStringDate() {
		// 获得当前时间的毫秒数
		Date da = new Date(System.currentTimeMillis());
		SimpleDateFormat sdFormatter = new SimpleDateFormat("yyyyMMddHHmmssSSS");
		String retStrFormatNowDate = sdFormatter.format(da);
		return retStrFormatNowDate;
	}
	public static String NewStringDate11() {
		// 获得当前时间的毫秒数
		Date da = new Date(System.currentTimeMillis());
		SimpleDateFormat sdFormatter = new SimpleDateFormat("ddHHmmssSSS");
		String retStrFormatNowDate = sdFormatter.format(da);
		return retStrFormatNowDate;
	}

	/**
	 * 返回当前时间的年份
	 * 
	 * @return
	 */
	@SuppressWarnings("deprecation")
	public static int getPuAiYear() {
		Date d = new Date();
		return d.getYear() + 1900;
	}

	/**
	 * 返回当前时间的月份
	 * 
	 * @return
	 */
	@SuppressWarnings("deprecation")
	public static int getPuAiMonth() {
		Date d = new Date();
		return d.getMonth() + 1;
	}

	/**
	 * 计算两个日期之间相差的天数
	 * 
	 * @param date1 小时间
	 * @param date2 大时间
	 * @return
	 */
	public static int daysBetween(Date date1, Date date2) {
		Calendar cal = Calendar.getInstance();
		cal.setTime(date1);
		long time1 = cal.getTimeInMillis();
		cal.setTime(date2);
		long time2 = cal.getTimeInMillis();
		long between_days = (time2 - time1) / (1000 * 3600 * 24);
		return Integer.parseInt(String.valueOf(between_days));
	}
}
